package com.meitun.mama.ui.main;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

/**
 * Created by sunny01 on 2016/3/27.
 */
public class CommonStatePagerAdapter extends FragmentStatePagerAdapter {
    private final int size = 5;
    private Fragment[] fragments;
    public CommonStatePagerAdapter(FragmentManager fm) {
        super(fm);
        fragments = new Fragment[size];
    }

    @Override
    public int getCount() {
        return size;
    }

    @Override
    public Fragment getItem(int position) {
        if (fragments[position] == null) {
            fragments[position] = new TestFragment();
            Bundle data = new Bundle();
            data.putString("test", "Test : "+position);
            fragments[position].setArguments(data);
        }

        return fragments[position];
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_UNCHANGED;
    }

    @Override
    public void startUpdate(ViewGroup container) {
        super.startUpdate(container);
    }
}
